package com.suiwei.quartz.config.listener;

import com.suiwei.quartz.config.QuartzConfig;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;
import javax.annotation.Resource;

/**自定义一个监听器，监听web启动,web启动后，启动定时任务
 * ApplicationListener监听spring容器的启动事件
 * @author suiwei
 * @date 2022-12-07 17:22
 */
@Configuration
public class QuartzListener implements ApplicationListener<ContextRefreshedEvent> {
  @Resource
  private QuartzConfig quartzConfig;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        //System.out.println("项目启动了");
        //quartzConfig.startJob();
        //System.out.println("定时任务启动了");
    }
}
